var p = new Promise( function (resolve, reject) {

    // 异步操作的代码 1. 定时器 2. ajax 请求
    var xhr = new XMLHttpRequest();
    xhr.open('get', 'url');
    xhr.onreadystatechange = function () {
        if(xhr.readyState == 4){
            console.log(xhr.responseText);
            resolve(xhr.responseText);
        }
    }
    xhr.send();

} );

p.then(data=>{
    console.log(data);
})
